/** @file               sw_tui.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of the swallow library
 *  @author             $Author: flyfish $
 *  @version            $Rev: 385 $
 *  @date               $Date: 2016-12-22 00:12:05 +0800 (周四, 22 12月 2016) $
 */
#ifndef __SW_TUI_H__
#define __SW_TUI_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef enum _SW_TUI_WIN_TYPE
{
    SW_TWT_WIN,
    SW_TWT_LABEL,
    SW_TWT_PUSHBUTTON,
    SW_TWT_SPINBOX,
    SW_TWT_COMBOBOX
}SW_TUI_WIN_TYPE;

typedef enum _SW_TUI_WIN_MSG
{
    SW_TWM_CREATE,
    SW_TWM_PAINT,
    SW_TWM_SHOW,
    SW_TWM_HIDE,
    SW_TWM_ENABLE,
    SW_TWM_DISABLE,
    SW_TWM_DESTROY,
    SW_TWM_CMD,
    SW_TWM_SETTEXT,
    SW_TWM_GETTEXT,
    SW_TWM_KEYDOWN,
    SW_TWM_KEYUP,
    SW_TWM_CLICK,
    SW_TWM_INVALID = -1
}SW_TUI_WIN_MSG;

typedef enum _SW_TUI_KEY_CODE
{
    SW_TKC_ENTER,
    SW_TKC_UP,
    SW_TKC_DOWN,
    SW_TKC_LEFT,
    SW_TKC_RIGHT,
    SW_TKC_ESC,
    SW_TKC_POWER,
    SW_TKC_INVALID = -1
}SW_TUI_KEY_CODE;

typedef enum _SW_TUI_CMD_MSG
{
    SW_TCM_CLICKED,
    SW_TCM_SELCHANGE,
    SW_TCM_SETFOCUS,
    SW_TCM_KILLFOCUS,
    SW_TCM_INVALID = -1
}SW_TUI_CMD_MSG;

typedef SW_VOID *SW_TUI;
#define SW_INVALID_TUI NULL

typedef SW_RET (*SW_TUI_WIN_PROC)(SW_TUI tui, SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
typedef SW_RET (*SW_TUI_TEXT_OUT_PROC)(SW_UINT32 winId, SW_TUI_WIN_TYPE type, SW_BOOL enable, SW_BOOL visible, const SW_CHAR *pText
                                       , SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign, SW_V_ALIGN vAlign, SW_UINT32 x
                                       , SW_UINT32 y, SW_UINT32 width, SW_UINT32 height, SW_UINT32 data);

SW_API SW_RET SW_InitTuiAPI(SW_VOID);
SW_API SW_RET SW_RunTuiAPI(SW_VOID);
SW_API SW_RET SW_StopTuiAPI(SW_VOID);
SW_API SW_RET SW_ExitTuiAPI(SW_VOID);
SW_API SW_TUI_WIN_MSG SW_TuiGetWinMsg(const SW_CHAR *pStr);
SW_API const SW_CHAR *SW_TuiGetWinMsgStr(SW_TUI_WIN_MSG winMsg);
SW_API SW_TUI_KEY_CODE SW_TuiGetKeyCode(const SW_CHAR *pStr);
SW_API const SW_CHAR *SW_TuiGetKeyCodeStr(SW_TUI_KEY_CODE keyCode);
SW_API SW_TUI_CMD_MSG SW_TuiGetCmdMsg(const SW_CHAR *pStr);
SW_API const SW_CHAR *SW_TuiGetCmdMsgStr(SW_TUI_CMD_MSG cmdMsg);
SW_API SW_RET SW_TuiDefWinProc(SW_TUI tui, SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiSetDcProc(SW_TUI_TEXT_OUT_PROC textOutProc);
SW_API SW_RET SW_TuiSendMsg(SW_TUI tui, SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiNotifyFocusWin(SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiNotifyFocusCtrl(SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiNotifySubCtrl(SW_TUI tui, SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiNotifyParent(SW_TUI tui, SW_TUI_WIN_MSG winMsg, SW_TUI_CMD_MSG cmdMsg, SW_UINT32 arg1, SW_UINT32 arg2);
SW_API SW_RET SW_TuiShowWin(SW_TUI tui);
SW_API SW_RET SW_TuiHideWin(SW_TUI tui);
SW_API SW_BOOL SW_TuiIsVisible(SW_TUI tui);
SW_API SW_RET SW_TuiEnableWin(SW_TUI tui);
SW_API SW_RET SW_TuiDisableWin(SW_TUI tui);
SW_API SW_BOOL SW_TuiIsDisabled(SW_TUI tui);
SW_API SW_TUI SW_TuiGetParent(SW_TUI tui);
SW_API SW_TUI SW_TuiGetFocusCtrl(SW_TUI tui);
SW_API SW_BOOL SW_TuiIsCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetFirstCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetLastCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetPrevCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetNextCtrl(SW_TUI tui);
SW_API SW_BOOL SW_TuiIsTabCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetFirstTabCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetLastTabCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetPrevTabCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetNextTabCtrl(SW_TUI tui);
SW_API SW_TUI SW_TuiGetFocusWin(SW_TUI tui);
SW_API SW_UINT32 SW_TuiGetWinId(SW_TUI tui);
SW_API SW_TUI SW_TuiGetDesktop(SW_VOID);
SW_API SW_TUI SW_TuiGetWin(SW_TUI parent, SW_UINT32 winId);
SW_API SW_RET SW_TuiSetWinText(SW_TUI tui, const SW_CHAR *pText);
SW_API SW_RET SW_TuiGetWinText(SW_TUI tui, SW_CHAR *pText, SW_UINT32 textLen);
SW_API SW_RET SW_TuiSetWinTextHAlign(SW_TUI tui, SW_H_ALIGN hAlign);
SW_API SW_RET SW_TuiSetWinTextVAlign(SW_TUI tui, SW_V_ALIGN vAlign);
SW_API SW_TUI SW_TuiCreateMainWin(const SW_CHAR *pTitle, SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign
                                  , SW_V_ALIGN vAlign, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y, SW_UINT32 width
                                  , SW_UINT32 height, SW_UINT32 data, SW_TUI_WIN_PROC proc);
SW_API SW_TUI SW_TuiCreateWin(const SW_CHAR *pTitle, SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign
                              , SW_V_ALIGN vAlign, SW_TUI parent, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y
                              , SW_UINT32 width, SW_UINT32 height, SW_UINT32 data, SW_TUI_WIN_PROC proc);
SW_API SW_RET SW_TuiDeleteWin(SW_TUI tui);
SW_API SW_RET SW_TuiDestroyWin(SW_TUI tui);
SW_API SW_TUI SW_TuiCreateLabel(const SW_CHAR *pTitle, SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign
                                , SW_V_ALIGN vAlign, SW_TUI parent, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y
                                , SW_UINT32 width, SW_UINT32 height, SW_UINT32 data);
SW_API SW_TUI SW_TuiCreatePushButton(const SW_CHAR *pTitle, SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign
                                     , SW_V_ALIGN vAlign, SW_TUI parent, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y
                                     , SW_UINT32 width, SW_UINT32 height, SW_UINT32 data);
SW_API SW_TUI SW_TuiCreateComboBox(SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign
                                   , SW_V_ALIGN vAlign, SW_TUI parent, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y
                                   , SW_UINT32 width, SW_UINT32 height, SW_UINT32 data, const SW_CHAR *pPrefix
                                   , const SW_CHAR *pSuffix);
SW_API SW_RET SW_TuiAddComboBoxItem(SW_TUI tui, const SW_CHAR *pItemStr, SW_UINT32 data);
SW_API SW_UINT32 SW_TuiGetComboBoxItemCount(SW_TUI tui);
SW_API SW_UINT32 SW_TuiGetComboBoxItemData(SW_TUI tui, SW_UINT32 index);
SW_API SW_RET SW_TuiGetComboBoxItemStr(SW_TUI tui, SW_UINT32 index, SW_CHAR *pItemStr, SW_UINT32 itemStrLen);
SW_API SW_RET SW_TuiSetComboBoxCurSel(SW_TUI tui, SW_UINT32 curSel);
SW_API SW_RET SW_TuiSetComboBoxNextSel(SW_TUI tui);
SW_API SW_RET SW_TuiSetComboBoxPrevSel(SW_TUI tui);
SW_API SW_UINT32 SW_TuiGetComboBoxCurSel(SW_TUI tui);
SW_API SW_RET SW_TuiSetComboBoxPrefix(SW_TUI tui, const SW_CHAR *pPrefix);
SW_API SW_RET SW_TuiSetComboBoxSuffix(SW_TUI tui, const SW_CHAR *pSuffix);
SW_API SW_TUI SW_TuiCreateSpinBox(SW_UINT32 fontSize, const SW_COLOR *pColor, SW_H_ALIGN hAlign, SW_V_ALIGN vAlign
                                  , SW_TUI parent, SW_UINT32 winId, SW_UINT32 x, SW_UINT32 y, SW_UINT32 width
                                  , SW_UINT32 height, SW_UINT32 data, SW_INT32 valueMin, SW_INT32 valueMax
                                  , SW_INT32 step, const SW_CHAR *pPrefix, const SW_CHAR *pSuffix);
SW_API SW_RET SW_TuiSetSpinBoxValue(SW_TUI tui, SW_INT32 value);
SW_API SW_RET SW_TuiIncSpinBoxValue(SW_TUI tui);
SW_API SW_RET SW_TuiDecSpinBoxValue(SW_TUI tui);
SW_API SW_RET SW_TuiSetSpinBoxLimit(SW_TUI tui, SW_INT32 valueMin, SW_INT32 valueMax, SW_INT32 step);
SW_API SW_INT32 SW_TuiGetSpinBoxValue(SW_TUI tui);
SW_API SW_RET SW_TuiSetSpinBoxPrefix(SW_TUI tui, const SW_CHAR *pPrefix);
SW_API SW_RET SW_TuiSetSpinBoxSuffix(SW_TUI tui, const SW_CHAR *pSuffix);
#ifndef SW_V_DISABLE_CMDSERVER
SW_API SW_RET SW_CmdTuiNotifyFocusWin(const SW_CHAR *pWinMsg, const SW_CHAR *pCmdMsg, const SW_CHAR *pArg1, const SW_CHAR *pArg2);
SW_API SW_RET SW_CmdTuiNotifyFocusCtrl(const SW_CHAR *pWinMsg, const SW_CHAR *pCmdMsg, const SW_CHAR *pArg1, const SW_CHAR *pArg2);
#endif

#ifdef __cplusplus
}
#endif

#endif
